#include <iostream>
#include "./aip-cpp-sdk/speech.h"

using namespace std;
using namespace aip;
string app_id = "17496766";
string api_key = "gG1oXkYhqC72KbsfKNawHZNv";
string secret_key = "ijAXKgNwUaQZbbVXryZmef6DnouQ6EnS";

int main()
{
	aip::Speech client(app_id, api_key, secret_key);

	ofstream ofile;
	string file_ret;

	map<string, string> options;

	options["aue"]="6";

	char line[100]={'\0'};

	ofile.open("test.wav", ios::out|ios::binary);
	//while(1)
	{
	fgets(line,sizeof(line),stdin);
	Json::Value result = client.text2audio(line, options, file_ret);
	if (!file_ret.empty()) {
		ofile << file_ret;
	}
	else {
		cout << result.toStyledString();
	}

	system("aplay -q test.wav");
	}
	return 0;
}

